#ifndef __PA_MW__H__
#define __PA_MW__H__

#include <stdint.h>
#include "pacmn.h"

#ifdef __cplusplus
extern "C"{
#endif

//#define MW_LTE_LPA                               1
#define MW_GSM_LNA_SKIP                          1

#define MW_RSP_FLAG_OK                           0x00
#define MW_RSP_FLAG_ERR_CRC                      0x01
#define MW_RSP_FLAG_ERR_CMD_NUM                  0x02
#define MW_RSP_FLAG_ERR_CMD_DATA                 0x03
#define MW_RSP_FLAG_ERR_PROC                     0x04

#define MW_MSG_HEAD_FLAG                         0x7B
#define MW_MSG_TAIL_FLAG                         0x7D

#define MW_MOD_ADDR_FUNC_PA                      0x05
#define MW_MOD_ADDR_FUNC_LNA                     0x06
#define MW_MOD_ADDR_FUNC_TD                      0x07

#define MW_MOD_ADDR_DL                           0
#define MW_MOD_ADDR_UL                           1

#define MW_CMD_SET_MOD_ADDR                      0x10
#define MW_CMD_SET_ATT                           0x20
#define MW_CMD_SET_SWITCH                        0x21
#define MW_CMD_SET_ALC                           0x22

#define MW_CMD_SET_SWITCH_RF                     0x32

#define MW_CMD_GET_MOD_SWVER                     0x60
#define MW_CMD_GET_MOD_STATUS                    0x61

#define MW_SWITCH_RF_OPEN                        0x00
#define MW_SWITCH_RF_LNA_OPEN                    0x01
#define MW_SWITCH_RF_PA_OPEN                     0x02
#define MW_SWITCH_RF_CLOSE                       0x03

#define MW_CMD_OFFSET_HEAD_FLAG                  0x00
#define MW_CMD_OFFSET_MOD_ADDR                   0x01
#define MW_CMD_OFFSET_MOD_ADDR_FUNC              0x01
#define MW_CMD_OFFSET_MOD_ADDR_CODE              0x02
#define MW_CMD_OFFSET_CMD_CODE                   0x03
#define MW_CMD_OFFSET_RSP_FLAG                   0x04
#define MW_CMD_OFFSET_CMD_SIZE                   0x05
#define MW_CMD_OFFSET_CMD_DATA                   0x06

#define MW_LPA_POWER_OFF                         0x0
#define MW_LPA_POWER_ON                          0x1

typedef struct tag_mw_lna_status {
    uint8_t state;
    int8_t att;
    int8_t power;
    int8_t alc;
} mw_lna_status;

typedef struct tag_mw_pa_status {
    uint8_t state;
    int8_t opower;
    int8_t rpower;
    uint8_t att;
    int8_t alc;
    int8_t temp;
    uint8_t swratio;
    int8_t ipower;
    int8_t spower;
} mw_pa_status;

pa_ret_t mw_get_pa_status(int32_t com_fd, mod_addr_t *pa_addr, mw_pa_status *status);

pa_ret_t mw_get_lna_status(int32_t com_fd, mod_addr_t *lna_addr, mw_lna_status *status);

pa_ret_t mw_get_pa_sw_ver(int32_t com_fd, mod_addr_t *pa_addr, char* sw_ver);

pa_ret_t mw_set_mod_addr(int32_t com_fd, mod_addr_t *mod_addr, uint8_t new_addr);

pa_ret_t mw_set_mod_switch(int32_t com_fd, mod_addr_t *mod_addr, int8_t on_off);

pa_ret_t mw_set_mod_switch_rf(int32_t com_fd, mod_addr_t *mod_addr, int8_t on_off);

pa_ret_t mw_set_mod_att(int32_t com_fd, mod_addr_t *mod_addr, int8_t att, bool save_eeprom = false);

#ifdef __cplusplus
}
#endif

#endif //__PA_MW__H__
